import { Injectable } from '@nestjs/common';
import { Book1Dto } from '../dto/book1.dto';

@Injectable()
export class Book1Service {
  private books: Book1Dto[] = [
    { id: 1, title: 'NestJS 入门指南', author: '张三', price: 49.9 },
    { id: 2, title: 'TypeScript 实战', author: '李四', price: 59.9 },
    { id: 3, title: 'Node.js 高级编程', author: '王五', price: 69.9 },
  ];

  findAll(): Book1Dto[] {
    return this.books;
  }

  findOne(id: number): Book1Dto | string {
    const book = this.books.find(book => book.id === id);
    return book || '图书不存在';
  }
}